﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace DAO
{
   public class DataProvider
    {
          private SqlConnection connect;
           private SqlCommand command;
           private string connectString = "Data Source=.\\SQLExpress;Initial Catalog=QuanLyKhachSan;Integrated Security=True";
           public DataProvider()
           {
               connect = new SqlConnection(connectString);
               command = new SqlCommand();
               command.Connection = connect;
           }
           public void Connect()
           {
               connect.Open();
           }
           public void Disconnect()
           {
               connect.Close();
           }
           public SqlDataReader ExecuteQuery(String sql)
           {
               command.CommandText = sql;
               return command.ExecuteReader();
           }
           public object ExecuteQueryScalar(string sql)
           {
               command.CommandText = sql;
               return command.ExecuteScalar();
           }
           public int ExecuteNonQuery(String sql)
           {
               command.CommandText = sql;
               return command.ExecuteNonQuery();
           }
      
    }
}
